<template>
	<view>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
			<view class="u-m-r-10">
				<u-avatar :src="pic" size="140"></u-avatar>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20">{{userNickname}}</view>
				<view class="u-font-14 u-tips-color">用户名:{{username}}</view>
			</view>
			<view class="u-m-l-10 u-p-10">
				<navigator url="../personDetail/personDetail">
					<u-icon name="arrow-right" color="#969799" size="28"></u-icon>
				</navigator>
			</view>
		</view>

		<navigator url="../changePass/changePass">
			<view class="u-m-t-20">
				<u-cell-group>
					<u-cell-item icon="https://chenxiaotian.oss-cn-hangzhou.aliyuncs.com/icon/static/img/xiugaimima.png"
						title="修改密码"></u-cell-item>
				</u-cell-group>
			</view>

		</navigator>
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item
					icon="https://chenxiaotian.oss-cn-hangzhou.aliyuncs.com/icon/static/img/changjianwentixiangguanwenti.png"
					title="常见问题"></u-cell-item>
				<u-cell-item icon="https://chenxiaotian.oss-cn-hangzhou.aliyuncs.com/icon/static/img/wodefankui.png"
					title="我的反馈"></u-cell-item>
			</u-cell-group>
		</view>

		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item
					icon="https://chenxiaotian.oss-cn-hangzhou.aliyuncs.com/icon/static/img/cuowutishi-copy.png"
					title="关于">v1.0</u-cell-item>
			</u-cell-group>
		</view>

		<view class="u-m-t-20">
			<u-modal v-model="show1" :content="content" @confirm="confirm" :mask-close-able="true" :zoom="true">
			</u-modal>
			<u-button type="primary" :ripple="true" ripple-bg-color="#909399" @click="logout">退出登录</u-button>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				pic: '',
				show: true,
				userNickname: '',
				username: '',
				show1: '',
				content: '是否确认退出登录',
				avatarUrl: '',
				nickName: ''
			}
		},
		onShow() {
			this.username = wx.getStorageSync("username");
			this.userNickname = wx.getStorageSync("userNickname");
			this.pic = wx.getStorageSync("userAvatar")
		},
		onLoad() {

		},
		methods: {
			async logout() {
				this.show1 = true;
				this.username = wx.getStorageSync("username");
				let params = {
					username: this.username,
				};
				const res = await uni.$http.post('logout',params);
				console.log(res)
			},
			confirm() {
				wx.clearStorage();
				wx.clearStorageSync();
				wx.redirectTo({
					//保留当前页面，跳转到应用内的某个页面
					url: '/pages/login/login'
				})
			}

		},
		onReady() {

		}
	}
</script>

<style lang="scss">
	.u-m-r-10 {
		margin-top: 10rpx;
	}

	page {
		background-color: #ededed;
	}

	.camera {
		width: 54px;
		height: 44px;

		&:active {
			background-color: #ededed;
		}
	}

	.user-box {
		background-color: #fff;
	}

	.u-m-t-20 button {
		width: 50%;
		margin-top: 100rpx;
	}
</style>
